Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatcher middleware for task orchestrations and task activities #95

Merged
merged 1 commit into from
Jun 7, 2017

Conversation

cgillum
Copy link
Collaborator

@cgillum cgillum commented Jun 5, 2017

This PR enables developers to add AspNetCore-style middleware to the task and activity dispatcher components. This custom middleware executes after the dispatcher has loaded the activity/orchestration but before it runs the executor logic.

Adding middleware is as simple as this:

TaskHubWorker worker = ...;
worker.AddOrchestrationDispatcherMiddleware(async (context, next) =>
{
    // pre-execute...
    await next();
    // post-execute...
});

worker.AddActivityDispatcherMiddleware(async (context, next) =>
{
    // pre-execute...
    await next();
    // post-execute...
});

You can add as many delegates as you want and they will be executed in-order for each task/orchestration execution. The context object contains a property bag as well as a few useful items from the runtime, like the OrchestrationInstance, OrchestrationRuntimeState, etc, that can be shared across middleware components of the same type.

See the new test code for more examples.

Example scenarios include adding diagnostics, monitoring, metering, etc. into the dispatch pipeline.

@cgillum cgillum self-assigned this Jun 5, 2017
@msftclas
Copy link

msftclas commented Jun 5, 2017

@cgillum,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@simonporter simonporter merged commit fffab58 into Azure:vnext Jun 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants